using System;
using System.Collections.Generic;
using System.Text;
using SdlDotNet.Graphics.Sprites;
using SdlDotNet.Graphics;
using SdlDotNet.Core;
using System.Drawing;
using SnakeCharp.Entity;

namespace SnakeCharp.UI
{
    public class DebugHud : Sprite
    {
        private UIFont fps;
        private UIFont secondsElapsed;
        private UIFont ticksElapsed;
        private UIFont playerInfo;

        private List<UIFont> guiCollection;

        public DebugHud() : base(new Surface(230, 75, Configurations.BitsPerPixel, true))
        {
            guiCollection = new List<UIFont>();
            this.X = 5;
            this.Y = 5;

            //Setup the individuel objects for the DebugHUD
            fps = new UIFont("FPS: ", 13);
            fps.Position = new Point(5, 0);

            secondsElapsed = new UIFont("SecondsElapsed: ", 13);
            secondsElapsed.Position = new Point(5, 15);

            ticksElapsed = new UIFont("TicksElapsed: ", 13);
            ticksElapsed.Position = new Point(5, 30);

            playerInfo = new UIFont("Player: ", 13);
            playerInfo.Position = new Point(5, 45);

            //Add to the collection being Blit's to the DebugHUD Surface
            guiCollection.Add(fps);
            guiCollection.Add(secondsElapsed);
            guiCollection.Add(ticksElapsed);
            guiCollection.Add(playerInfo);


            //Basic settings for the DebugHUD
            //this.Transparent = true;
            this.AlphaBlending = true;
            this.Alpha = 150;
            //this.TransparentColor = System.Drawing.Color.Black;

            //TEST: Test of Hardware Surface
            //this.Surface = this.Surface.Convert(this.Surface, true, false);
        }

        public void Update(TickEventArgs e, Snake player)
        {
            //Clear the DebugHUD Surface
            this.Surface.Fill(Color.Gray);

            //Blit all components to the DebugHUD
            fps.Text = "FPS: " + e.Fps;
            secondsElapsed.Text = "SecondsElapsed: " + e.SecondsElapsed;
            ticksElapsed.Text = "TicksElapsed: " + e.TicksElapsed;
            playerInfo.Text = "Player Position: X = " + player.X + " Y = " + player.Y;

            //Blit all to the DebugHUD Surface
            foreach (UIFont ui in guiCollection)
            {
                this.Surface.Blit(ui);
            }
        }

    }
}
